import random

def generate_test_cases(num_cases=5, min_size=3, max_size=10, min_rating=0, max_rating=5):
    """
    生成测试用例
    :param num_cases: 测试用例数量
    :param min_size: 最小数组长度
    :param max_size: 最大数组长度
    :param min_rating: 最小评分
    :param max_rating: 最大评分
    :return: 测试用例列表
    """
    test_cases = []
    for _ in range(num_cases):
        size = random.randint(min_size, max_size)
        ratings = [random.randint(min_rating, max_rating) for _ in range(size)]
        test_cases.append(ratings)
    return test_cases

def save_test_cases(test_cases, filename="test_cases.txt"):
    """
    保存测试用例到文件
    """
    with open(filename, "w") as f:
        for case in test_cases:
            f.write(f"{case}\n")

if __name__ == "__main__":
    # 生成测试用例
    test_cases = generate_test_cases()
    # 保存测试用例
    save_test_cases(test_cases)
    print("测试用例已生成并保存到 test_cases.txt") 